package moonstruckdrops;

import org.apache.wicket.Application;
import org.apache.wicket.Request;
import org.apache.wicket.RequestCycle;
import org.apache.wicket.Response;
import org.apache.wicket.protocol.http.HttpSessionStore;
import org.apache.wicket.protocol.http.WebApplication;
import org.apache.wicket.protocol.http.WebRequest;
import org.apache.wicket.protocol.http.WebResponse;
import org.apache.wicket.session.ISessionStore;
import org.apache.wicket.settings.IExceptionSettings;

import moonstruckdrops.page.EntryPage;
import moonstruckdrops.page.ErrorPage;
import moonstruckdrops.page.ManagementPage;
import moonstruckdrops.util.ErrorRequestCycle;

public class GoogleAppEngineBlogApplication extends WebApplication {
	public GoogleAppEngineBlogApplication() {
	}

	protected void init() {
		super.init();
		/*
		 * リクエスト・レスポンス時の文字エンコード
		 */
		getRequestCycleSettings().setResponseRequestEncoding( "UTF-8");
		/*
		 * HTMLファイルのエンコード
		 */
		getMarkupSettings().setDefaultMarkupEncoding( "UTF-8");
		mountBookmarkablePage("/manegement",ManagementPage.class);
		this.getResourceSettings().setResourcePollFrequency(null);
		getApplicationSettings().setInternalErrorPage(ErrorPage.class);
		getExceptionSettings().setUnexpectedExceptionDisplay(IExceptionSettings.SHOW_INTERNAL_ERROR_PAGE);
		
	}
	
	public RequestCycle newRequestCycle(Request request, Response response) {
		return new ErrorRequestCycle(this, (WebRequest)request, (WebResponse)response);
	}
	
	@Override
	public String getConfigurationType() {
		return Application.DEPLOYMENT;
	}

	@Override
	protected ISessionStore newSessionStore() {
		return new HttpSessionStore(this);
	}
	
	public Class<EntryPage> getHomePage() {
		return EntryPage.class;
	}
}
